package com.zhixi.pattern.important.prototypepattern.deepprototypepattern;

import com.zhixi.pattern.important.prototypepattern.deepprototypepattern.operation.Sheep;
import com.zhixi.pattern.important.prototypepattern.deepprototypepattern.operation.SheepClone;

/**
 * 深拷贝原型模式
 *
 * @作者 ShuHaoNan
 * @邮箱 shuhaonan1@gmail.com
 * @时间 2020/11/15 14:00
 */
public class DeepPrototypePattern {

    public static void main(String[] args) {
        Sheep sheep = new Sheep("tom", 1, "白色", new SheepClone("jack", 2, "黑色"));
        Sheep sheep1 = sheep.clone();
        System.out.println(sheep.hashCode());
        System.out.println(sheep1.hashCode());
        System.out.println(sheep);
        System.out.println(sheep1);
        // 克隆的引用类型hashcode不一样了，深拷贝
        System.out.println(sheep.getSheepClone().hashCode());
        System.out.println(sheep1.getSheepClone().hashCode());
    }

}
